<?php
if (!defined('IN_D')) die("Error 404");
if(!$cmd[1]) $cmd[1]="main";
if($cmd[1]=='main'){
$ju=$tpl->get_tpl("main_home");
	$main_content=$ju;
$sql=$DB->query("SELECT * FROM {$conf['prefix']}media WHERE m_multimedia=0 OR m_multimedia IN (select multi_id from {$conf['prefix']}multimedia where multi_type=1) ORDER BY m_id DESC LIMIT {$conf['media_per_page']}");
$tt=$DB->num_rows($sql);
	if ($tt) {
		$ro = $tpl->get_tpl('list_media');
		$t['row'] = $tpl->get_block_from_str($ro,'list_media.row',1);
		
		$html = '';
		$list_title=$lang['latest_songs'];
		$list_title_ascii="latest_songs";
		while ($song = $DB->fetch_row($sql)) {
			static $i = 0;	
			$singer_name=$func->get_data('singer',$song['m_singer']);
			$html .= $tpl->assign_vars($t['row'],
				array(
				'song.TITLE'	=> $func->unhtmlchars($song['m_title']),
				'song.TYPE'		=> "<img src='{TPL_LINK}/".$func->get_data('player',$song['m_type'])."' border=0 >",
				'song.ID'		=> $song['m_id'],	
				'song.VIEWED'	=> $song['m_viewed'],
				'song.DOWNLOADED' => $song['m_downloaded'],
				'song.SINGER_NAME' => $singer_name,
				'song.SINGER_URL' => $func->change_link('singer',$song['m_singer'],$func->title_2_ascii($singer_name,true)),
				'song.URL'		=> $func->change_link('song',$song['m_id'],$func->title_2_ascii($song['m_title_ascii'])),
				'song.ADD_PL'	=> $logged_in?"select_playlist({$song['m_id']});return false;":"guest_playlist({$song['m_id']});return false;",
				)
			);
			$i++;
		}
			$ro=$tpl->unset_block($ro,array('album_in_cat'));
		$ro = $tpl->assign_vars($ro,
			array(
				'list.TITLE' => $list_title,
				'list.TOTAL'	=> "",
				'list.PAGES' => "",
			)
		);
		
		$ro = $tpl->assign_blocks_content($ro,array(
				'list_media'	=>	$html,
			)
		);
		
	
	}
	else $ro=box_announcement($lang['no_data']);
	$main_content.="\n".$ro;

}
?>
